home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Original Code / Brushes and Pens / TwoTriangleTile / TwoTriangleTile.cs next >
Encoding:
Text File  |  2001-01-15  |  1.3 KB  |  42 lines

  1. //----------------------------------------------
  2. // TwoTriangleTile.cs ⌐ 2001 by Charles Petzold
  3. //----------------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Drawing.Drawing2D;
  7. using System.Windows.Forms;
  8.  
  9. class TwoTriangleTile: PrintableForm
  10. {
  11.      const int iSide = 50;         // Side of square for triangle
  12.  
  13.      public new static void Main()
  14.      {
  15.           Application.Run(new TwoTriangleTile());
  16.      }
  17.      public TwoTriangleTile()
  18.      {
  19.           Text = "Two-Triangle Tile";
  20.      }
  21.      protected override void DoPage(Graphics grfx, Color clr, int cx, int cy)
  22.      {
  23.                // Define the triangle and create the first brush.
  24.  
  25.           Point[] apt = 
  26.                {new Point(0, 0), new Point(iSide, 0), new Point(0, iSide)};
  27.  
  28.           PathGradientBrush pgbrush1 = 
  29.                          new PathGradientBrush(apt, WrapMode.TileFlipXY);
  30.  
  31.                // Define another triangle and create the second brush.
  32.  
  33.           apt = new Point[] {new Point(iSide, 0), new Point(iSide, iSide), 
  34.                              new Point(0, iSide)};
  35.  
  36.           PathGradientBrush pgbrush2 = 
  37.                          new PathGradientBrush(apt, WrapMode.TileFlipXY);
  38.  
  39.           grfx.FillRectangle(pgbrush1, 0, 0, cx, cy);
  40.           grfx.FillRectangle(pgbrush2, 0, 0, cx, cy);
  41.      }
  42. }